#include "RemoteCtlWidget.h"
#include "ui_RemoteCtlWidget.h"
#include"MainWindow.h"
RemoteCtlWidget::RemoteCtlWidget(MainWindow* mw,QWidget *parent) :
    mw(mw),
    QWidget(parent),
    ui(new Ui::RemoteCtlWidget)
{
    ui->setupUi(this);
    setWindowTitle("remoteCtl");
}

RemoteCtlWidget::~RemoteCtlWidget()
{
    delete ui;
}

void RemoteCtlWidget::test()
{
    ui->showFrame->beginUpdateFrame();
}

void RemoteCtlWidget::resizeEvent(QResizeEvent *event)
{
    QWidget::resizeEvent(event);
    int w = this->width();
    int h = this->height();
    int openGLh = this->ui->showFrame->height();
    ui->showFrame->resize(w,openGLh);
}

void RemoteCtlWidget::on_close_clicked()
{
    //1. 通知被控端
    mw->remoteCli->reqCloseRemoteCtl();
    //2. 关闭当前窗口(关闭接收服务器、解码器、渲染)
    ui->showFrame->endUpdateFrame();
    mw->remoteCli->recFraSrv->stopServer();//解码器会在关闭接收服务器后自动关闭
    this->hide();
}
